layout.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use client";
  2. import Box from "@/components/Box";
  3. import Header from "@/components/Header";
  4. import { usePathname } from "@/i18n";
  5. import { FC, PropsWithChildren, ReactNode, useEffect, useRef } from "react";
  6. type Props = {
  7. swiperWidget: ReactNode;
  8. popupWidget: ReactNode;
  9. cardWidget: ReactNode;
  10. noticeWidget: ReactNode;
  11. searchWidget: ReactNode;
  12. prizeWidget: ReactNode;
  13. };
  14. const Layout: FC<PropsWithChildren<Props>> = (props) => {
  15. const {
  16. children,
  17. swiperWidget,
  18. popupWidget,
  19. cardWidget,
  20. noticeWidget,
  21. searchWidget,
  22. prizeWidget,
  23. ...other
  24. } = props;
  25. const barRef = useRef<HTMLDivElement>(null);
  26. // 获取分享id
  27. const pathname = usePathname();
  28. useEffect(() => {
  29. const [, shareId] = pathname.split("/");
  30. if (!shareId || shareId === "xxxxxx") return;
  31. sessionStorage.setItem("shareId", shareId);
  32. }, []);
  33. return (
  34. <>
  35. <Header {...other}></Header>
  36. <main id="maincontainer" className={"main-footer-header"}>
  37. {/*弹窗*/}
  38. {popupWidget}
  39. <Box>
  40. {/* swiper */}
  41. {swiperWidget}
  42. {/* swiper下的活动 */}
  43. {cardWidget}
  44. {/* 跑马灯 */}
  45. {noticeWidget}
  46. {/* 搜索组件 */}
  47. {searchWidget}
  48. {/* 搜索下面的大奖展示 */}
  49. {prizeWidget}
  50. </Box>
  51. {/* tabs 和 游戏列表 */}
  52. {children}
  53. </main>
  54. </>
  55. );
  56. };
  57. export default Layout;